/**
 * 
 */
package com.tdkj.action.common;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.tdkj.action.BaseAction;
import com.tdkj.model.user.BeanFindPasswordTemp;
import com.tdkj.model.user.BeanUser;

/**
 * 
 * FileName: InitAction.java
 * 
 * @Description: TODO 重新设置密码，在密码找回的动作中 All rights Reserved, Designed By ZTE-ITS
 * 
 *               Copyright: Copyright(C) 2010-2011
 * 
 *               Company 天成科技有限公司
 * 
 * @author: 李兴建
 * 
 * @version V1.0
 * 
 *          Createdate: 2012-7-23 下午03:44:23
 * 
 * 
 * 
 *          Modification History:
 * 
 *          Date Author Version Discription
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 *          
 *          ----------------------------------------------------------------------
 *          -------------
 * 
 *          2012-7-23 李兴建 1.0 1.0
 * 
 *          Why & What is modified: <修改原因描述>
 */
public class ReSetPasswordAction extends BaseAction {
	private static final long serialVersionUID = 1L;
	private String toker;

	// 新密码
	private String newPassword;
	// 再次确认密码
	private String confimPasword;

	/**
	 * 重设密码页面
	 * 
	 * @return
	 */
	public String reSetPage() {
		if (StringUtils.isEmpty(toker)) {
			this.addFieldError("erroeinfo", "你的密码修改信息不正确");
			return SUCCESS;
		}
		List<BeanFindPasswordTemp> list = null;
		list = this.getBaseService().findByProperty("toker", toker, BeanFindPasswordTemp.class);
		if (null == list || list.size() < 1) {
			this.addFieldError("erroeinfo", "你的密码修改信息不正确");
		}

		return SUCCESS;
	}

	/**
	 * 保存密码
	 * 
	 * @return
	 */

	public String savePassword() {
		if (StringUtils.isEmpty(toker)) {
			this.addFieldError("erroeinfo", "你的密码修改信息不正确");
			return SUCCESS;
		}
		List<BeanFindPasswordTemp> list = null;
		list = this.getBaseService().findByProperty("toker", toker, BeanFindPasswordTemp.class);
		if (null != list || list.size() > 0) {
			BeanFindPasswordTemp beanFindPasswordTemp = null;
			beanFindPasswordTemp = list.get(0);
			if (null == beanFindPasswordTemp) {
				this.addFieldError("erroeinfo", "你提交的信息不正确，请重试");
				return SUCCESS;
			}
			//do 还没写完
			BeanUser beanUser = this.getBaseService().findById(beanFindPasswordTemp.getUserid(), BeanUser.class);

		} else {
			this.addFieldError("erroeinfo", "你提交的信息不正确，请重试");
			return SUCCESS;
		}
		return SUCCESS;
	}

	public String getToker() {
		return toker;
	}

	public void setToker(String toker) {
		this.toker = toker;
	}

	public String getNewPassword() {
		return newPassword;
	}

	public void setNewPassword(String newPassword) {
		this.newPassword = newPassword;
	}

	public String getConfimPasword() {
		return confimPasword;
	}

	public void setConfimPasword(String confimPasword) {
		this.confimPasword = confimPasword;
	}

}
